#pragma once
class CTangoThreadPoolWorkerThread : public JetByteTools::Win32::CThreadPool::WorkerThread
{
public:

	CTangoThreadPoolWorkerThread(
		JetByteTools::Win32::CIOCompletionPort &iocp,
		JetByteTools::Win32::CEvent &messageReceivedEvent,
		CTangoThreadPool &pool);

private:

	virtual bool Initialise();

	virtual void Process(
		ULONG_PTR completionKey,
		DWORD dwNumBytes,
		OVERLAPPED *pOverlapped);

	virtual void Shutdown();

	void ProcessMessage(
		JetByteTools::Win32::CSocketServer::Socket *pSocket,
		JetByteTools::Win32::CIOBuffer *pBuffer) const;

	void OnConnectionEstablished(
		JetByteTools::Win32::CSocketServer::Socket *pSocket,
		JetByteTools::Win32::CIOBuffer *pAddress);

	void OnConnectionClosing(
		JetByteTools::Win32::CSocketServer::Socket *pSocket);

	void OnConnectionClosed(
		JetByteTools::Win32::CSocketServer::Socket *pSocket);

	CTangoThreadPool &m_pool;

	// No copies do not implement
	CTangoThreadPoolWorkerThread(const CTangoThreadPoolWorkerThread &rhs);
	CTangoThreadPoolWorkerThread &operator=(const CTangoThreadPoolWorkerThread &rhs);
};

